package com.qcby.shujia.demo.config;

import com.qcby.shujia.demo.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @className: WebMvcConfig
 * @description: mvc配置类
 * @author: whz
 * @date: 2021/9/23
 **/

@Configuration
public class WebMvcConfig implements WebMvcConfigurer{
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/login/**","/error","/swagger-ui.html/**","/swagger-resources/**");
    }

    @Bean//将拦截器放置进容器
    public LoginInterceptor loginInterceptor(){
        return new LoginInterceptor();
    }
 }
